#pragma once

#include<iostream>
#include<assert.h>
#include<string.h>

using namespace std;

namespace zhaojiahao
{
	class string
	{
	public:
		//string(const char* str="")
		string(const char* str="")
		{
			_size = strlen(str);
			_capacity = _size;
			_str = new char[_capacity + 1];
			strcpy(_str,str);
 		}
		~string()
		{
			delete[] _str;
			_str = nullptr;
			_size = 0;
			_capacity = 0;
		}
		
		const char* c_str() const
		{
			return _str;
		}
		char& operator[](size_t pos)
		{
			assert(pos < _size);
			return _str[pos];
		}
		const char& operator[](size_t pos) const
		{
			assert(pos < _size);
			return _str[pos];
		}
		size_t size()
		{
			return _size;
		}

		size_t capacity()
		{
			return _capacity;
		}



	private:
		char* _str=nullptr;
		int _size=0;
		int _capacity=0;
	};



}
